package work.array;

/**
 * @author WDH
 * @description
 * @date 2024年12月04日 15:48
 */

public class Problem704 {

    public int search(int[] nums, int target) {
        int right = nums.length - 1;
        int left = 0;
        while (left <=right) {
            int mid = (left + right) / 2;
            if (nums[mid] == target) return target;
            if (nums[mid] > target) {
                right = mid - 1;
            } else {
                left = mid + 1;
            }
        }
        return -1;
    }

}
